

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
import { PageParams } from '@/types';
import { EditLove } from './EditLove';
import { LoveList } from './LoveList';
import { LoveTabs } from './LoveTabs';



export default async function Page({searchParams}: { searchParams: PageParams & {tab: string} }) {
  console.log('params', searchParams)
  const { offset = 1, limit = 10, tab = 'who' } = searchParams;
  let ls = [];
  let total = 0;
  if (tab === 'who') {

    ls = await prisma.loveWhoCard.findMany()
    // 获取总数
    total = await prisma.loveWhoCard.count()
  } else {
    ls = await prisma.loveDoCard.findMany()
    // 获取总数
    total = await prisma.loveDoCard.count()
  }

  return (
    <div className="text-[#333] p-4">
      <LoveTabs />
      <EditLove type='add' />
      <LoveList books={ls} total={total} />
    </div>
  )
}